<?php

namespace App\Repositories\Eloquent;

use Prettus\Repository\Eloquent\BaseRepository;
use Prettus\Repository\Criteria\RequestCriteria;
use App\Repositories\Contract\ColumnRepository;
use App\Models\Column;
use App\Validators\ColumnValidator;

/**
 * Class ColumnRepositoryEloquent.
 *
 * @package namespace App\Repositories\Eloquent;
 */
class ColumnRepositoryEloquent extends BaseRepository implements ColumnRepository
{
    /**
     * Specify Model class name
     *
     * @return string
     */
    public function model()
    {
        return Column::class;
    }

    /**
     * @inheritDoc
     */
    public function copy(Column $column, int $projectId, int $prevId = 0): Column
    {
        $payload = $column->only([
            'title',
            'description',
            'frozen',
            'hidden',
            'type'
        ]);
        $payload['prev_id'] = $prevId;
        $payload['project_id'] = $projectId;
        return $this->create($payload);
    }

    /**
     * Boot up the repository, pushing criteria
     */
    public function boot()
    {
        $this->pushCriteria(app(RequestCriteria::class));
    }
    
}
